minor changes
cleaned up code. fixed multiple bugs