Prologue 2

Refactored some of the code. History to be added.