fixed bugs + new functionality

major cleanup