1) ASSERT. Catch the mistakes while they're still dumb.
2) Take advantage of your type checker to catch mistakes.