minor bugfixes and cleanup, correct license