Add custom data format function
Clean up scattered vars