Added particle class and code refactoring