Util updates and fixes

Fixed instances where fclose was called with an invalid handle. Added
functions for padding vectors.