Initial implementation
minor code cleanup