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

Merge from Remote:BitShares