Code improvements for use as example