copy and merge from google code