fixed warnings, cleaned up code