improve code consistency, cleanup, fix bugs, add config file, add license