Cleanup and refactory