Fixed loads of stuff and added comments.