Engine cleanup.
Removed dead/unused functions from engine.
Further engine cleanup.
Moved string trimming functions to seperate utils module.
Engine code cleanup:

- Put functions in sensible order in file.
- Added missing prototypes
- Removed unneeded headers
- General cleanup.