It works! Major rewrite, major fixes