Added various helper functions to reduce code size.

Not sure about performance effect. (But that's not even a concern yet)