Implemented unit costs, and added debug messages.