Add some state and minor fixes to function definitions
skeleton