Random bugfixes + improvements