more code and fixes