Lots of bug fixes and caching works for PA1. Haven't implemented taking the life expectancy into account yet.