Make improvements as suggested by @bmjames