Fix lot of bugs and add class diagram