Implement conditional attribute append in compiler

Also some code minor code cleanup