Cleaned up code. instant initalization and file writes working.