Added improvements by jsmeix