Improve implementation of integration and clean commented code