minor improvments in mechanics
added calls to console.log to debug some internals