Cleanup and make code more readable