Multiple masters support, some bugfixes