Rewrite in Swift

Following earthreader/web rewrite branch