version 0.6.0 release, code refactored into functions, added main() function, reformatted comments