bunch of changes and fixes