Fix up coding style + iron out patterns code