Optimized text.asm

Various optimizations in text.asm. Please don't merge for now.