Added state.c module for maintining global state