Refactored the actual code in order to try and please travis-ci tests. This better work.