Refactoring for API friendliness

-added logic to determine team based on player
-code cleanup