Component creation functions changed to return status

Restructured the creation functions to return error codes
rather than the components themselves. Makes error handling
a little more sensible.

+ added a missing function comment