some cleanup, bug fixing