Miranda fixes. Partial fix to #119