Add stricter checking and fix some errors that arose

Adds stricter checking so we don't do stupid things in the code.