master: merged changes and refactoring