Refactor and Cleanup