added zerofill, some code cleanup