some fixes, still needs more documentation