Fixed some minor bugs and rearrange attributes