Removed test code, slight modifications