More generalisation and cleanup