Code tidy and spec update