Various fixes discovered upon first use of the library

Mainly PHPDoc type-hinting and some bugs