Made code actually work, minor fixes.