add examples and code cleanup