port bug fixes from vedis
Merge pull request #4 from Yuras/port_fixes_from_vedis

port bug fixes from vedis