Some fixes and simplifications