Code and fixes