cleaned up logging
fixed bugs where it was trying to put metadata into database