Heavy code refactor and callbacks added.