Better variable names: p<var> for all pointers
Transfer create table code to a function
Code clean, remove unused variable and commented lines