Removed more duplicated code
Bug fixes
Bug fixes