Refactored code (many optimizations, added formatters...)