Filled in subroutine code

All subroutines return a structure with a "->error" field which
indicate success or error status.