Cleanup and make code more consistent