API improved, code-cleanup

untested!