Cleanup and general fixes