Fixed bugs, now compiles and links