testing working, a few bugs fixed as a result