Refactoring banksim.c and fixed some mutex issues.