bug fixes, not quite fixed yet
bug fixes so it now works