Incorporated improvements by Hannah