Clean up and bug fixes