Fixed init functions and small bugfixes.