Made some changes.
Fixed and merged refactoring.