Bug fixing, code refactoring and documentation update.