Added a missing directory.
Rearranged some functions to remove the need for prototypes, also
make a bit of the code more explicit.