Cleanup of code and turn system