fixed id handling (issue 4) and general improvements.