fixed a lot and organized the code

 Please enter the commit message for your changes. Lines starting