Added init and deinit. Converted SMA to new format.