Some fixes in the engine