Some fixes and clean up