Added state_machine and added states to loans.