Fixed lost funds during failed transactions.

Also added .gitignore to prevent bin folder from being added to repo.