Upgrade to Intellij14 (new gradle and android lib) and bugfixes.

Bugs fixed:
- Database closed when it shouldn't.
- Sometimes calculations failed resulting in result 0 due to different scales.