various bugfixes, simplified api