Cleanup code, make more readable