Introduced max swap distance in decoder, bug fixing