diff --git a/athenasub/athenasub_2008.vcproj b/athenasub/athenasub_2008.vcproj
index d4f569ed24d08c1eb1eda06338715faf5ad134e0..ecae2d67df39844841f9a3aace8ac045cbad1c08 100644
--- a/athenasub/athenasub_2008.vcproj
+++ b/athenasub/athenasub_2008.vcproj
@@ -319,6 +319,10 @@
 		<Filter
 			Name="Formats"
 			>
+			<File
+				RelativePath=".\src\format_handler.cpp"
+				>
+			</File>
 			<File
 				RelativePath=".\src\format_handler.h"
 				>
diff --git a/athenasub/include/athenasub/interfaces.h b/athenasub/include/athenasub/interfaces.h
index 7650aa55ddfe5d1c2e4436300c3625610888049a..786cf0455adfe120c878cf8627434347b8381248 100644
--- a/athenasub/include/athenasub/interfaces.h
+++ b/athenasub/include/athenasub/interfaces.h
@@ -66,6 +66,7 @@ namespace Athenasub {
 	class IDeltaCoder;
 	class CController;
 	class CAction;
+	class IAction;
 
 
 	// Smart pointers
@@ -83,6 +84,7 @@ namespace Athenasub {
 	typedef shared_ptr<INotification> Notification;
 	typedef shared_ptr<ISection> Section;
 	typedef shared_ptr<IDeltaCoder> DeltaCoder;
+	typedef shared_ptr<IAction> Action;
 
 
 	// Const smart pointers
@@ -100,27 +102,6 @@ namespace Athenasub {
 
 	// Model
 	class IModel {
-		friend class CFormatHandler;
-		friend class CActionList;
-		friend class CController;
-		friend class CAction;
-
-	protected:
-		virtual void ProcessActionList(CActionList &actionList,int type=0) = 0;
-
-		virtual void Undo(const String owner="") = 0;
-		virtual void Redo(const String owner="") = 0;
-		virtual void ActivateStack(ActionStack stack,bool isUndo,const String &owner) = 0;
-
-		virtual void DispatchNotifications(Notification notification) const = 0;
-
-		virtual void Clear() = 0;
-		virtual void Load(Reader &input,Format format=Format()) = 0;
-
-		virtual Section AddSection(String name) = 0;
-		virtual Section GetMutableSection(String name) = 0;
-		virtual Section GetMutableSectionByIndex(size_t index) = 0;
-
 	public:
 		virtual ~IModel() {}
 
@@ -335,8 +316,6 @@ namespace Athenasub {
 
 
 	// Action interface
-	class IAction;
-	typedef shared_ptr<IAction> Action;
 	class IAction {
 	public:
 		virtual ~IAction() {}
@@ -415,7 +394,6 @@ namespace Athenasub {
 	class ILibAthenaSub {
 	public:
 		virtual ~ILibAthenaSub() {}
-
 		virtual Model CreateModel()=0;
 	};
 	typedef shared_ptr<ILibAthenaSub> LibAthenaSub;
diff --git a/athenasub/src/action.cpp b/athenasub/src/action.cpp
index c383ecb0ed5517be094be3b38fa7fa052e300502..01b9e6ad73ae292d11389513659165574299ed52 100644
--- a/athenasub/src/action.cpp
+++ b/athenasub/src/action.cpp
@@ -48,6 +48,16 @@ CAction::CAction(Model _model)
 	if (!model) THROW_ATHENA_EXCEPTION(Exception::Internal_Error);
 }
 
+Model CAction::GetModel() const
+{
+	return model;
+}
+
+Section CAction::GetSection(String name) const
+{
+	return static_pointer_cast<CModel>(model)->GetMutableSection(name);
+}
+
 
 ///////////////////////////// Insert line /////////////////////////////
 
diff --git a/athenasub/src/action.h b/athenasub/src/action.h
index 548653574f6e18f078410a3c88f80485c3c35b89..2251b1bdbafc7fa52759166ea476880757484342 100644
--- a/athenasub/src/action.h
+++ b/athenasub/src/action.h
@@ -43,13 +43,13 @@ namespace Athenasub {
 	// Action base class
 	class CAction : public IAction {
 	private:
-		mutable Model model;
+		Model model;
 
 	protected:
 		CAction(Model model);
 
-		Model GetModel() const { return model; }
-		Section GetSection(String name) const { return model->GetMutableSection(name); }
+		Model GetModel() const;
+		Section GetSection(String name) const;
 	};
 
 	// Insert line
diff --git a/athenasub/src/actionlist.cpp b/athenasub/src/actionlist.cpp
index c199a974e6eb6765fcdd561493a401e09fbbd16c..1289a7fc018c3ba8720cd29bd08c669ec8173fd0 100644
--- a/athenasub/src/actionlist.cpp
+++ b/athenasub/src/actionlist.cpp
@@ -41,7 +41,7 @@ using namespace Athenasub;
 ///////////////
 // Constructor
 CActionList::CActionList(weak_ptr<IModel> _model,String _actionName,const String _owner,bool _undoAble)
-: model(_model), owner(_owner), undoAble(_undoAble)
+: model(dynamic_pointer_cast<CModel>(Model(_model))), owner(_owner), undoAble(_undoAble)
 {
 	valid = false;
 	Start(_actionName);
@@ -96,7 +96,7 @@ void CActionList::Start(const String name)
 void CActionList::Finish()
 {
 	if (valid) {
-		Model(model)->ProcessActionList(*this);
+		shared_ptr<CModel>(model)->ProcessActionList(*this);
 		actions.clear();
 		valid = false;
 	}
@@ -125,7 +125,7 @@ void CActionList::RemoveLine(int position,const String section)
 // Insert a "modify line" action
 Entry CActionList::ModifyLine(int position,const String section)
 {
-	Section sect = Model(model)->GetMutableSection(section);
+	Section sect = shared_ptr<CModel>(model)->GetMutableSection(section);
 	Entry entry = sect->GetEntry(position)->Clone();
 	Action action = Action (new ActionModify(model.lock(),entry,position,section,false));
 	AddAction(action);
@@ -138,7 +138,7 @@ Entry CActionList::ModifyLine(int position,const String section)
 std::vector<Entry> CActionList::ModifyLines(Selection selection,const String section)
 {
 	// Get section
-	Section sect = Model(model)->GetMutableSection(section);
+	Section sect = shared_ptr<CModel>(model)->GetMutableSection(section);
 
 	// Generate entries
 	std::vector<Entry> entries(selection->GetCount());
diff --git a/athenasub/src/actionlist.h b/athenasub/src/actionlist.h
index f19e5dfcb06fe18b2d2ed0233c8308be3526adc7..faff26ed36ba624101216e0b8a208442dafe77fe 100644
--- a/athenasub/src/actionlist.h
+++ b/athenasub/src/actionlist.h
@@ -56,7 +56,7 @@ namespace Athenasub {
 	private:
 		String actionName;
 		String owner;
-		weak_ptr<IModel> model;
+		weak_ptr<CModel> model;
 		std::list<Action> actions;
 		bool valid;
 		bool undoAble;
diff --git a/athenasub/src/controller.cpp b/athenasub/src/controller.cpp
index 82c4926da18c0293ddca7e4a298a09187ed4b404..b10e8080f7d27894286fa2d12b679707e4326eeb 100644
--- a/athenasub/src/controller.cpp
+++ b/athenasub/src/controller.cpp
@@ -46,7 +46,7 @@ using namespace Athenasub;
 ///////////////
 // Constructor
 CController::CController(Model _model)
-: model(_model)
+: model(dynamic_pointer_cast<CModel>(_model))
 {
 }
 
diff --git a/athenasub/src/controller.h b/athenasub/src/controller.h
index 8af2d3614596eed61bfe8db85fffa853dc1c582e..11847bf4ea53a15a5f338dc540ec9fa0678279cd 100644
--- a/athenasub/src/controller.h
+++ b/athenasub/src/controller.h
@@ -43,7 +43,7 @@ namespace Athenasub {
 		friend class CModel;
 
 	private:
-		Model model;
+		shared_ptr<CModel> model;
 		CController (Model model);
 
 	public:
diff --git a/athenasub/src/format_handler.cpp b/athenasub/src/format_handler.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2a894a8397af57edfdd734fbab021b98db87d916
--- /dev/null
+++ b/athenasub/src/format_handler.cpp
@@ -0,0 +1,68 @@
+// Copyright (c) 2008, Rodrigo Braz Monteiro
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+//   * Redistributions of source code must retain the above copyright notice,
+//     this list of conditions and the following disclaimer.
+//   * Redistributions in binary form must reproduce the above copyright notice,
+//     this list of conditions and the following disclaimer in the documentation
+//     and/or other materials provided with the distribution.
+//   * Neither the name of the Aegisub Group nor the names of its contributors
+//     may be used to endorse or promote products derived from this software
+//     without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+//
+// -----------------------------------------------------------------------------
+//
+// AEGISUB/ATHENASUB
+//
+// Website: http://www.aegisub.net
+// Contact: mailto:amz@aegisub.net
+//
+
+#include "format_handler.h"
+#include "model.h"
+using namespace Athenasub;
+
+
+Section CFormatHandler::AddSection(IModel &model,String name) const
+{
+	return (dynamic_cast<CModel*>(&model))->AddSection(name);
+}
+
+ConstSection CFormatHandler::GetSection(const IModel &model,String name) const
+{
+	return model.GetSection(name);
+}
+
+ConstSection CFormatHandler::GetSectionByIndex(const IModel &model,size_t index) const
+{
+	return model.GetSectionByIndex(index);
+}
+
+Section CFormatHandler::GetSection(IModel &model,String name) const
+{
+	return (dynamic_cast<CModel*>(&model))->GetMutableSection(name); 
+}
+
+Section CFormatHandler::GetSectionByIndex(IModel &model,size_t index) const
+{
+	return (dynamic_cast<CModel*>(&model))->GetMutableSectionByIndex(index);
+}
+
+size_t CFormatHandler::GetSectionCount(const IModel &model) const {
+	return model.GetSectionCount();
+}
diff --git a/athenasub/src/format_handler.h b/athenasub/src/format_handler.h
index 526c57f404344a98c57f3b6294ad0a1e974990fa..065562c3efee54e81c9bea07a86f0fe27df653ba 100644
--- a/athenasub/src/format_handler.h
+++ b/athenasub/src/format_handler.h
@@ -45,12 +45,12 @@ namespace Athenasub {
 	protected:
 		virtual ~CFormatHandler() {}
 
-		Section AddSection(IModel &model,String name) const { return model.AddSection(name); }
-		ConstSection GetSection(const IModel &model,String name) const { return model.GetSection(name); }
-		ConstSection GetSectionByIndex(const IModel &model,size_t index) const { return model.GetSectionByIndex(index); }
-		Section GetSection(IModel &model,String name) const { return model.GetMutableSection(name); }
-		Section GetSectionByIndex(IModel &model,size_t index) const { return model.GetMutableSectionByIndex(index); }
-		size_t GetSectionCount(const IModel &model) const { return model.GetSectionCount(); }
+		Section AddSection(IModel &model,String name) const;
+		ConstSection GetSection(const IModel &model,String name) const;
+		ConstSection GetSectionByIndex(const IModel &model,size_t index) const;
+		Section GetSection(IModel &model,String name) const;
+		Section GetSectionByIndex(IModel &model,size_t index) const;
+		size_t GetSectionCount(const IModel &model) const;
 
 	public:
 		//CFormatHandler(IModel& _model) : model(_model) {}
diff --git a/athenasub/src/text_reader_cache.cpp b/athenasub/src/text_reader_cache.cpp
index 81189f084c17942a8afa363ab131693b63ff1073..99dc79ef5ee32d76f8fc7dbf39ea874e1bb40df6 100644
--- a/athenasub/src/text_reader_cache.cpp
+++ b/athenasub/src/text_reader_cache.cpp
@@ -48,7 +48,7 @@ Athenasub::TextReaderCache::TextReaderCache(shared_ptr<TextReader> src)
 String TextReaderCache::ReadLineFromFile()
 {
 	if (bufferPos == buffer.size()) {
-		LoadMore(1000000);
+		LoadMore(1);
 	}
 	if (bufferPos == buffer.size()) {
 		return "";