First version of the code: everything should work smoothly... bug fixes to come!