Removed run-time casts from gate. It's all static now.