a lot of changes and fixes for better view of code