Refactoring

Fixed few issues