Code cleanup for better readability and structure