Updated and simplified a ton.