Reorganize code; add updating capability