Bugfixes and reorg repo