Modifications
- fix some issues
- place the code properly