fixed some bugs, so no more errors when initialising