Plain: more performance enhancements, fixed a potential startup problem

Thanks in advance for merging this.