Added argument validation function
Fixed all compilation errors
Finally correct