Improve logging and return structure