Basic logic in, though not runnable version.