Changed function cp to getPlayer + minor changes.