more code cleanup, still in a very intermediate state of things not working