some safety first checks and minor optimizations
remove trailing \t
simplify loading commands to avoid stack frames