Fixed bugs (random algorithm now works). Other minor changes.
Added the first fully-working output.