refactor internals towards complete functionality