rewrote part of the implementation

1. added new features;
2. fixed a bug in normal calculation;
3. cleaned project.