Fixed minification issue + some refactoring