Fix analyzer bug that would nest previous statements onto next ones.
Implement extend-type and extend-protocol