tested, fixed minor bugs, ready to merge