Fixed items not attaching to correct modules.

Also changed id generator for API 16 and below to random int [0, max_int)
for all classes concerned.

Signed-off-by: nicholaslum444 <nicholaslum444@hotmail.com>