Structure cleanup and base library for both programs