Fix type casting and PlayerState struct