Cleaned up code for a fresh start