Updated with geometrics, datastructures and extra graph stuff.