fixed a number of issues with coercions;
added comments