Some refactoring done
Bug fixes