Completed state writing process. Some tests should be added still,
however.