Some code fixes, change design