Code cleanup and final touches