Cleanup & add err checking