code cleanup, bug fixes, and readme update