Fixed result code passing, fixes #16