Optimization

This PR will contain some optimizations.

* Type parameters where possible.
* Fix the return type of functions where needed.
* Evaluate several points together when possible.