Added log function, other minor adjustments