Remove some bugs, better code