Fix mono AOT assert error. Closes #155.
Replace runtime type casting with static.