Squashed version of PR 259

This is a ready-to-merge version of all commits regarding Pull Request #259. 
Tests are passing locally. Should we merge?