Bz bug refactoring

Those commits try to reduce the size of methods inside our Rails app while moving stuff around to their correct location (move more methods into models!)

I also started to format the code so that it respects the 80 chars per line limit and applied some of the tips in the [Ruby Style Guide][ruby_guide]  page. All these changes actually will cause a lot of tiny changes in the code as a result.

I will continue to work on it and push to the PR until I am satisfied with how things look. This PR is submitted in the meantime for potential comments.

[ruby_guide]: https://github.com/bbatsov/ruby-style-guide