Tweaks and bug fixes; seems to work now