General tweaking and bug fixing