Refactor and Clean up Code Base