Added SMX feature and refactored code.