Improvements from svick (code review) carried out.