Algorithm was tested. Bugs were fixed.