moved more scaffolding code into main
replaced TRUE and FALSE with stdbool true and false