More comments, error handling and bug fixes
Added post validation