minor changes
add gpl license info
remove unused and refactor some vars
implement class for api query
.