Fixes, cleanup and codestyle