better debugging, fix potential errors
Merge pull request #132 from BitShares/master

Merge from Remote:BitShares