fixed multiple bugs, clean up