fixes, cleanup and comments