Fixed issues with new code

Added doco