Split code to multiple files
Fix function naming
Better error messages