Tighten up input error checking