improved handling of 0 padding