Added small functional. Fixed few bugs