Fix bugs, update headers