First bulk of refactoring. Backend, output unification, jshint.

Signed-off-by: Kirill Enykeev <enykeev@gmail.com>
Fix memory calculations

Signed-off-by: Kirill Enykeev <enykeev@gmail.com>