Add libraries and fixed small bugs so that it compiles.