Removed unused directives. Refactored code.