Improved padzeros function, so that it gets a smarter type.