First working implementation of the bookkeeping.

Signed-off-by: Cyde Weys <cydeweys@gmail.com>