Completion

- Completion of the code
- some minor bug fixes