Fixed some bugs and added padding

#553