Major refactor: now prototype based.