bug fixes, better docs, removed redundant code