some game mechanics, some code reorganization