Fix and Optimization

fixes #83
fixes #84