A load of new library methods, plus some fixes and niceties.

This is probably the least professional commit of all time. It does about a million things.
Add a few more functional library functions, and tidy up the ones which were there.

Also added some helpers to make pushing values onto the callstack easier to read.