Fixing bugs, now compiles and runs